package com.mobilebsc.datatype;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;


public class StrategicGoal {
	private int id;
	private String name;
	private String description;
	private ArrayList<KPI> kpis;

	/**
	 * Constructor for empty strategic goals
	 */
	public StrategicGoal() {
		this.id = -1;
		this.name = "null";
		this.description = "null";
		this.kpis = new ArrayList<KPI>();
	}
	
	/**
	 * Use constructor to create strategic goal from JSONObject
	 * @param strategicGoalJSON
	 * @throws JSONException
	 */
	public StrategicGoal(JSONObject strategicGoalJSON) throws JSONException {
		this.id = strategicGoalJSON.getInt("id");
		this.name = strategicGoalJSON.getString("name");
		this.description = strategicGoalJSON.getString("description");
		this.kpis = new ArrayList<KPI>();
	}
	
    public StrategicGoal(int id, String name, String description) {
		super();
		this.id = id;
		this.name = name;
		this.description = description;
		this.kpis = new ArrayList<KPI>();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public ArrayList<KPI> getKpis()
    {
        return kpis;
    }

    public void setKpis(ArrayList<KPI> kpis)
    {
        this.kpis = kpis;
    }
    
	/**
	 * Returns strategic goal as a JSONObject
	 * 
	 * @return
	 * @throws JSONException
	 */
	public JSONObject getJSON() throws JSONException {
		JSONObject json = new JSONObject();

		json.put("id", getId());
		json.put("name", getName());
		json.put("description", getDescription());

		return json;
	}
}